package io.renren.modules.user.service.impl;

import io.renren.modules.user.entity.TApplyRecordEntity;
import io.renren.modules.user.entity.TPeopleEntity;
import io.renren.modules.user.service.TApplyRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.user.dao.TPeopleCopyDao;
import io.renren.modules.user.entity.TPeopleCopyEntity;
import io.renren.modules.user.service.TPeopleCopyService;


@Service("tPeopleCopyService")
public class TPeopleCopyServiceImpl extends ServiceImpl<TPeopleCopyDao, TPeopleCopyEntity> implements TPeopleCopyService {

    @Autowired
    private TPeopleCopyDao tPeopleCopyDao;
    @Autowired
    private TApplyRecordService tApplyRecordService;




    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<TPeopleCopyEntity> page = this.page(
                new Query<TPeopleCopyEntity>().getPage(params),
                new QueryWrapper<TPeopleCopyEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public void saveTPeople(TPeopleEntity tPeopleEntity) {
        tPeopleEntity.setApplyTime(new Date());
        tPeopleCopyDao.saveTPeople(tPeopleEntity);
        //生成审批信息
        TApplyRecordEntity tApplyRecordEntity=new TApplyRecordEntity();
        tApplyRecordEntity.setDataId(tPeopleEntity.getId());
        tApplyRecordEntity.setState("0");
        tApplyRecordService.save(tApplyRecordEntity);
    }

    @Override
    public TPeopleEntity findpeople(String peopleId) {
        TPeopleEntity findpeople = tPeopleCopyDao.findpeople(peopleId);
        return findpeople;
    }

}